
package no.uio.ifi.cop.prover.cmp;

import java.util.Comparator;

import no.uio.ifi.cop.prover.RuleMatcher;
import no.uio.ifi.cop.cl.Axiom;


/**
 * Natural ordering, that takes number of applications
 * into account, most used gets preference.
 *
 * @version 1.0
 * @author bjarneh@ifi.uio.no
 */

public class ReverseDynNatural implements Comparator<RuleMatcher>{

    public int compare(RuleMatcher first, RuleMatcher second){

        int firstType, secondType;

        if( first == second ){ return 0; }

        firstType   = first.getAxiom().getType();
        secondType  = second.getAxiom().getType();

        if( first.getId() == second.getId() ){ return 0; }

        if( firstType < secondType ){
            return -1;
        }else if( firstType > secondType ){
            return 1;
        }else{
            return ( first.applications() > second.applications() )? -1 : 1;
        }

    }
}
